package com.warm.base.design.b_iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @Date: 2019/11/27 16:28
 * @Author: LChuang
 * @Description:
 */
public class ConcreteAggregate extends Aggregate {

    private List<Object> list;

    public ConcreteAggregate(){
        this.list = new ArrayList<>();
    }

    public Object get(int index){
        return list.get(index);
    }

    public void add(Object obj){
        list.add(obj);
    }

    public int getSize(){
        return list.size();
    }

    @Override
    public Iterator iterator() {
        return new ConcreteIterator(this);
    }
}
